
<? include("/inc/header.html") {} ?>

<div class="col-lg-5">
	<div class="panel" overflow:auto;">
		<div class="panel-body pan " style="width:auto; overflow: auto;">
			<div class="form-body pal"
				style="float:left;width:100%; overflow: auto;">
				<div>
					<label for="inputUsername" class="col-md-3 control-label">
						<div align="right">关系中文名称 <span
						class='require'>*</span> 
						</div> </label>
					<div class="col-md-7">
						<div class="input-icon">
							<input id="nameZh" type="text" class="form-control" />
						</div>
					</div>
				</div>
				<div>
					<label for="inputUsername" class="col-md-3 control-label">
						<div align="right">关系英文名称 <span
						class='require'>*</span> 
						</div> </label>
					<div class="col-md-7">
						<div class="input-icon">
							<input id="nameEn" type="text" placeholder="建议使用大写字母利用英文下划线分割" class="form-control" />
						</div>
					</div>
				</div>

				<div>
					<label for="inputUsername" class="col-md-3 control-label">
						<div align="right">排序<span
						class='require'>*</span> 
						</div> </label>
					<div class="col-md-7">
						<div class="input-icon">
							<input id="sort" type="text" class="form-control" />
						</div>
					</div>
				</div>
				<div>
					<label for="inputUsername" class="col-md-3 control-label">
						<div align="right">关系描述
						</div> </label>
					<div class="col-md-7">
						<div class="input-icon">
							<textarea id="description"  rows="3" cols="20" class="form-control" ></textarea> 
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
	var moduleId = window.parent.getModule();
	var AddUpId = window.parent.getAddUpId();
	var curr = window.parent.getCurr();
	$(function() {
		if (AddUpId != '0') {
			demo();
		} 
	});
	function demo() {
		$.getJSON('queryWordRelation.do', {
			id : AddUpId
		//向服务端传的参数，此处只是演示
		}, function(res) {
			//此处仅仅是为了演示变化的内容
			$("#nameZh").val(res[0].nameZh);
			$("#nameEn").val(res[0].nameEn);
			$("#sort").val(res[0].sort);
			$("#description").val(res[0].description);
		});
	};
	function save() {
		 if($.trim($("#nameZh").val()).length<1) {
    	        	alert('中文名称不能为空！');
    	        	return null;
    	    }
		 if($.trim($("#nameEn").val()).length<1) {
    	        	alert('英文名称不能为空！');
    	        	return null;
    	    }
		 if($.trim($("#sort").val()).length<1) {
    	        	alert('排序不能为空！');
    	        	return null;
    	    }
		
		$.ajax({
			type : "post",
			url : "addOrUploadWordRelation.do",
			dataType : "json",
			data : {
				"nameZh" : $("#nameZh").val(),
				"nameEn" : $("#nameEn").val(),
				"sort" : $("#sort").val(),
				"description" : $("#description").val(),
				"moduleId" : moduleId,
				"wordRelationId" : AddUpId,
			},
			success : function (data) {
				var index = parent.layer.getFrameIndex(window.name);
				if(data[0].data == 'yes'){
					parent.layer.msg('编辑成功！');
				}else{
					parent.layer.msg('编辑失败！');
				}
				window.parent.queryWordRelation(curr);
				parent.layer.close(index);
			}
		});
	}
	
</script>

